/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hello;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
 * @author Fatec
 */
public class HelloMIDlet extends MIDlet implements CommandListener {

    private boolean midletPaused = false;

//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Command exitCommand;
    private Command temperaturaCommand;
    private Command pesoCommand;
    private Command comprimentoCommand;
    private Command backCommandtemperaturaCommand;
    private Command backCommandcomprimentoCommand;
    private Command backCommandpesoCommand;
    private Form formConversor;
    private StringItem stringItem;
    private ChoiceGroup opcoeschoiceGroup;
    private Form formPeso;
    private TextField pesoTextField;
    private ChoiceGroup pesoChoiceGroup;
    private StringItem libraStringItem;
    private StringItem kiloStringItem;
    private StringItem gramaStringItem;
    private Form formTemperatura;
    private TextField temperaturaTextField;
    private ChoiceGroup escalaChoiceGroup;
    private StringItem fahrenheitStringItem;
    private StringItem kelvinStringItem;
    private StringItem celsiusStringItem;
    private Form formComprimento;
    private TextField compTextField;
    private ChoiceGroup compChoiceGroup;
    private StringItem metroStringItem;
    private StringItem kmStringItem;
    private StringItem milhaStringItem;
//</editor-fold>//GEN-END:|fields|0|

    /**
     * The HelloMIDlet constructor.
     */
    public HelloMIDlet() {
    }

//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initializes the application. It is called only once when the MIDlet is
     * started. The method is called before the
     * <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getFormConversor());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The
     * <code>display</code> instance is taken from
     * <code>getDisplay</code> method. This method is used by all actions in the
     * design for switching displayable.
     *
     * @param alert the Alert which is temporarily set to the display;
     * if <code>null</code>, then <code>nextDisplayable</code> is set
     * immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a
     * particular displayable.
     *
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == formComprimento) {//GEN-BEGIN:|7-commandAction|1|43-preAction
            if (command == backCommandcomprimentoCommand) {//GEN-END:|7-commandAction|1|43-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormConversor());//GEN-LINE:|7-commandAction|2|43-postAction
        double comp = Double.parseDouble(compTextField.getString());
        double milha = 0, km = 0, metro = 0;
        if(compChoiceGroup.isSelected(0)){//metro
             metro = comp;
             milha = metro/1609;
             km = metro/1000;
        }else if(compChoiceGroup.isSelected(1)){//km
            km = comp;
            milha = km/1.609;         
            metro = km*1000;
        }else if(compChoiceGroup.isSelected(2)){//milha
             milha = comp;
             km = milha*1.609;
             metro = milha*1609;
          
        }
        milhaStringItem.setText(Double.toString(milha));
        kmStringItem.setText(Double.toString(km));
        metroStringItem.setText(Double.toString(metro));
            }//GEN-BEGIN:|7-commandAction|3|34-preAction
        } else if (displayable == formConversor) {
            if (command == comprimentoCommand) {//GEN-END:|7-commandAction|3|34-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormComprimento());//GEN-LINE:|7-commandAction|4|34-postAction
                // write post-action user code here
            } else if (command == exitCommand) {//GEN-LINE:|7-commandAction|5|19-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|6|19-postAction
                // write post-action user code here
            } else if (command == pesoCommand) {//GEN-LINE:|7-commandAction|7|32-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormPeso());//GEN-LINE:|7-commandAction|8|32-postAction
                // write post-action user code here
            } else if (command == temperaturaCommand) {//GEN-LINE:|7-commandAction|9|30-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormTemperatura());//GEN-LINE:|7-commandAction|10|30-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|11|41-preAction
        } else if (displayable == formPeso) {
            if (command == backCommandpesoCommand) {//GEN-END:|7-commandAction|11|41-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormConversor());//GEN-LINE:|7-commandAction|12|41-postAction
        double peso = Double.parseDouble(pesoTextField.getString());
        double libra = 0, kilo = 0, grama = 0;
        if(pesoChoiceGroup.isSelected(0)){//libra
            libra = peso;
            kilo = libra*0.45;
            grama = libra*0.45*1000;
        }else if(pesoChoiceGroup.isSelected(1)){//kilo
            kilo = peso;
            libra = kilo/0.45;         
            grama = kilo*1000;
        }else if(pesoChoiceGroup.isSelected(2)){//grama
             grama = peso;
            libra = grama/450;
            kilo = grama/1000;
          
        }
        libraStringItem.setText(Double.toString(libra));
        kiloStringItem.setText(Double.toString(kilo));
        gramaStringItem.setText(Double.toString(grama));
            }//GEN-BEGIN:|7-commandAction|13|39-preAction
        } else if (displayable == formTemperatura) {
            if (command == backCommandtemperaturaCommand) {//GEN-END:|7-commandAction|13|39-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormConversor());//GEN-LINE:|7-commandAction|14|39-postAction
        double temp = Double.parseDouble(temperaturaTextField.getString());
        double temp_c = 0, temp_f = 0, temp_k = 0;
        if(escalaChoiceGroup.isSelected(0)){//Celsius
            temp_c = temp;
            temp_f = temp*1.8+32;
            temp_k = temp+273.15;
        }else if(escalaChoiceGroup.isSelected(1)){//Far
            temp_c = (temp-32)/1.8;
            temp_f = temp;
            temp_k = temp_c-273.15;
        }else if(escalaChoiceGroup.isSelected(2)){//Kelvin
            temp_c = temp-273.15;
            temp_f = temp_c*1.8+32;
            temp_k = temp;
        }
        celsiusStringItem.setText(Double.toString(temp_c));
        fahrenheitStringItem.setText(Double.toString(temp_f));
        kelvinStringItem.setText(Double.toString(temp_k));
            }//GEN-BEGIN:|7-commandAction|15|7-postCommandAction
        }//GEN-END:|7-commandAction|15|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|16|
//</editor-fold>//GEN-END:|7-commandAction|16|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit
    /**
     * Returns an initialized instance of exitCommand component.
     *
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
            exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit
            // write post-init user code here
        }//GEN-BEGIN:|18-getter|2|
        return exitCommand;
    }
//</editor-fold>//GEN-END:|18-getter|2|
    //</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: formConversor ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initialized instance of formConversor component.
     *
     * @return the initialized component instance
     */
    public Form getFormConversor() {
        if (formConversor == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            formConversor = new Form("Conversor de medidas", new Item[]{getStringItem(), getOpcoeschoiceGroup()});//GEN-BEGIN:|14-getter|1|14-postInit
            formConversor.addCommand(getExitCommand());
            formConversor.addCommand(getTemperaturaCommand());
            formConversor.addCommand(getPesoCommand());
            formConversor.addCommand(getComprimentoCommand());
            formConversor.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
        }//GEN-BEGIN:|14-getter|2|
        return formConversor;
    }
//</editor-fold>//GEN-END:|14-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">//GEN-BEGIN:|16-getter|0|16-preInit
    /**
     * Returns an initialized instance of stringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getStringItem() {
        if (stringItem == null) {//GEN-END:|16-getter|0|16-preInit
            // write pre-init user code here
            stringItem = new StringItem("Escolha entre as op\u00E7\u00F5es de medidas:", "");//GEN-LINE:|16-getter|1|16-postInit
            // write post-init user code here
        }//GEN-BEGIN:|16-getter|2|
        return stringItem;
    }
//</editor-fold>//GEN-END:|16-getter|2|
    //</editor-fold>

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: opcoeschoiceGroup ">//GEN-BEGIN:|22-getter|0|22-preInit
    /**
     * Returns an initialized instance of opcoeschoiceGroup component.
     *
     * @return the initialized component instance
     */
    public ChoiceGroup getOpcoeschoiceGroup() {
        if (opcoeschoiceGroup == null) {//GEN-END:|22-getter|0|22-preInit
            // write pre-init user code here
            opcoeschoiceGroup = new ChoiceGroup("Op\u00E7\u00F5es:", Choice.EXCLUSIVE);//GEN-BEGIN:|22-getter|1|22-postInit
            opcoeschoiceGroup.append("Temperatura", null);
            opcoeschoiceGroup.append("Peso", null);
            opcoeschoiceGroup.append("Comprimento", null);
            opcoeschoiceGroup.setSelectedFlags(new boolean[]{false, false, false});//GEN-END:|22-getter|1|22-postInit
            // write post-init user code here
        }//GEN-BEGIN:|22-getter|2|
        return opcoeschoiceGroup;
    }
//</editor-fold>//GEN-END:|22-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: formTemperatura ">//GEN-BEGIN:|26-getter|0|26-preInit
    /**
     * Returns an initialized instance of formTemperatura component.
     *
     * @return the initialized component instance
     */
    public Form getFormTemperatura() {
        if (formTemperatura == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
            formTemperatura = new Form("Temperatura", new Item[]{getTemperaturaTextField(), getEscalaChoiceGroup(), getCelsiusStringItem(), getKelvinStringItem(), getFahrenheitStringItem()});//GEN-BEGIN:|26-getter|1|26-postInit
            formTemperatura.addCommand(getBackCommandtemperaturaCommand());
            formTemperatura.setCommandListener(this);//GEN-END:|26-getter|1|26-postInit
            // write post-init user code here
        }//GEN-BEGIN:|26-getter|2|
        return formTemperatura;
    }
//</editor-fold>//GEN-END:|26-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: formPeso ">//GEN-BEGIN:|27-getter|0|27-preInit
    /**
     * Returns an initialized instance of formPeso component.
     *
     * @return the initialized component instance
     */
    public Form getFormPeso() {
        if (formPeso == null) {//GEN-END:|27-getter|0|27-preInit
            // write pre-init user code here
            formPeso = new Form("Peso", new Item[]{getPesoTextField(), getPesoChoiceGroup(), getLibraStringItem(), getKiloStringItem(), getGramaStringItem()});//GEN-BEGIN:|27-getter|1|27-postInit
            formPeso.addCommand(getBackCommandpesoCommand());
            formPeso.setCommandListener(this);//GEN-END:|27-getter|1|27-postInit
            // write post-init user code here
        }//GEN-BEGIN:|27-getter|2|
        return formPeso;
    }
//</editor-fold>//GEN-END:|27-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: formComprimento ">//GEN-BEGIN:|28-getter|0|28-preInit
    /**
     * Returns an initialized instance of formComprimento component.
     *
     * @return the initialized component instance
     */
    public Form getFormComprimento() {
        if (formComprimento == null) {//GEN-END:|28-getter|0|28-preInit
            // write pre-init user code here
            formComprimento = new Form("Comprimento", new Item[]{getCompTextField(), getCompChoiceGroup(), getMetroStringItem(), getKmStringItem(), getMilhaStringItem()});//GEN-BEGIN:|28-getter|1|28-postInit
            formComprimento.addCommand(getBackCommandcomprimentoCommand());
            formComprimento.setCommandListener(this);//GEN-END:|28-getter|1|28-postInit
            // write post-init user code here
        }//GEN-BEGIN:|28-getter|2|
        return formComprimento;
    }
//</editor-fold>//GEN-END:|28-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: temperaturaCommand ">//GEN-BEGIN:|29-getter|0|29-preInit
    /**
     * Returns an initialized instance of temperaturaCommand component.
     *
     * @return the initialized component instance
     */
    public Command getTemperaturaCommand() {
        if (temperaturaCommand == null) {//GEN-END:|29-getter|0|29-preInit
            // write pre-init user code here
            temperaturaCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|29-getter|1|29-postInit
            // write post-init user code here
        }//GEN-BEGIN:|29-getter|2|
        return temperaturaCommand;
    }
//</editor-fold>//GEN-END:|29-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoCommand ">//GEN-BEGIN:|31-getter|0|31-preInit
    /**
     * Returns an initialized instance of pesoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getPesoCommand() {
        if (pesoCommand == null) {//GEN-END:|31-getter|0|31-preInit
            // write pre-init user code here
            pesoCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|31-getter|1|31-postInit
            // write post-init user code here
        }//GEN-BEGIN:|31-getter|2|
        return pesoCommand;
    }
//</editor-fold>//GEN-END:|31-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: comprimentoCommand ">//GEN-BEGIN:|33-getter|0|33-preInit
    /**
     * Returns an initialized instance of comprimentoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getComprimentoCommand() {
        if (comprimentoCommand == null) {//GEN-END:|33-getter|0|33-preInit
            // write pre-init user code here
            comprimentoCommand = new Command("Item", Command.ITEM, 0);//GEN-LINE:|33-getter|1|33-postInit
            // write post-init user code here
        }//GEN-BEGIN:|33-getter|2|
        return comprimentoCommand;
    }
//</editor-fold>//GEN-END:|33-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommandtemperaturaCommand ">//GEN-BEGIN:|38-getter|0|38-preInit
    /**
     * Returns an initialized instance of backCommandtemperaturaCommand
     * component.
     *
     * @return the initialized component instance
     */
    public Command getBackCommandtemperaturaCommand() {
        if (backCommandtemperaturaCommand == null) {//GEN-END:|38-getter|0|38-preInit
            // write pre-init user code here
            backCommandtemperaturaCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|38-getter|1|38-postInit
            // write post-init user code here
        }//GEN-BEGIN:|38-getter|2|
        return backCommandtemperaturaCommand;
    }
//</editor-fold>//GEN-END:|38-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommandpesoCommand ">//GEN-BEGIN:|40-getter|0|40-preInit
    /**
     * Returns an initialized instance of backCommandpesoCommand component.
     *
     * @return the initialized component instance
     */
    public Command getBackCommandpesoCommand() {
        if (backCommandpesoCommand == null) {//GEN-END:|40-getter|0|40-preInit
            // write pre-init user code here
            backCommandpesoCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|40-getter|1|40-postInit
            // write post-init user code here
        }//GEN-BEGIN:|40-getter|2|
        return backCommandpesoCommand;
    }
//</editor-fold>//GEN-END:|40-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommandcomprimentoCommand ">//GEN-BEGIN:|42-getter|0|42-preInit
    /**
     * Returns an initialized instance of backCommandcomprimentoCommand
     * component.
     *
     * @return the initialized component instance
     */
    public Command getBackCommandcomprimentoCommand() {
        if (backCommandcomprimentoCommand == null) {//GEN-END:|42-getter|0|42-preInit
            // write pre-init user code here
            backCommandcomprimentoCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|42-getter|1|42-postInit
            // write post-init user code here
        }//GEN-BEGIN:|42-getter|2|
        return backCommandcomprimentoCommand;
    }
//</editor-fold>//GEN-END:|42-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: temperaturaTextField ">//GEN-BEGIN:|44-getter|0|44-preInit
    /**
     * Returns an initialized instance of temperaturaTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getTemperaturaTextField() {
        if (temperaturaTextField == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
            temperaturaTextField = new TextField("Digite um valor:", "0", 32, TextField.DECIMAL);//GEN-LINE:|44-getter|1|44-postInit
            // write post-init user code here
        }//GEN-BEGIN:|44-getter|2|
        return temperaturaTextField;
    }
//</editor-fold>//GEN-END:|44-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: escalaChoiceGroup ">//GEN-BEGIN:|45-getter|0|45-preInit
    /**
     * Returns an initialized instance of escalaChoiceGroup component.
     *
     * @return the initialized component instance
     */
    public ChoiceGroup getEscalaChoiceGroup() {
        if (escalaChoiceGroup == null) {//GEN-END:|45-getter|0|45-preInit
            // write pre-init user code here
            escalaChoiceGroup = new ChoiceGroup("Escolha a escala:", Choice.EXCLUSIVE);//GEN-BEGIN:|45-getter|1|45-postInit
            escalaChoiceGroup.append("Celsius", null);
            escalaChoiceGroup.append("Kelvin", null);
            escalaChoiceGroup.append("Fahrenheit", null);
            escalaChoiceGroup.setSelectedFlags(new boolean[]{false, false, false});//GEN-END:|45-getter|1|45-postInit
            // write post-init user code here
        }//GEN-BEGIN:|45-getter|2|
        return escalaChoiceGroup;
    }
//</editor-fold>//GEN-END:|45-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: celsiusStringItem ">//GEN-BEGIN:|49-getter|0|49-preInit
    /**
     * Returns an initialized instance of celsiusStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getCelsiusStringItem() {
        if (celsiusStringItem == null) {//GEN-END:|49-getter|0|49-preInit
            // write pre-init user code here
            celsiusStringItem = new StringItem("Celsius", "-");//GEN-LINE:|49-getter|1|49-postInit
            // write post-init user code here
        }//GEN-BEGIN:|49-getter|2|
        return celsiusStringItem;
    }
//</editor-fold>//GEN-END:|49-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: kelvinStringItem ">//GEN-BEGIN:|50-getter|0|50-preInit
    /**
     * Returns an initialized instance of kelvinStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getKelvinStringItem() {
        if (kelvinStringItem == null) {//GEN-END:|50-getter|0|50-preInit
            // write pre-init user code here
            kelvinStringItem = new StringItem("Kelvin", "-");//GEN-LINE:|50-getter|1|50-postInit
            // write post-init user code here
        }//GEN-BEGIN:|50-getter|2|
        return kelvinStringItem;
    }
//</editor-fold>//GEN-END:|50-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: fahrenheitStringItem ">//GEN-BEGIN:|51-getter|0|51-preInit
    /**
     * Returns an initialized instance of fahrenheitStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getFahrenheitStringItem() {
        if (fahrenheitStringItem == null) {//GEN-END:|51-getter|0|51-preInit
            // write pre-init user code here
            fahrenheitStringItem = new StringItem("Fahrenheit", "-");//GEN-LINE:|51-getter|1|51-postInit
            // write post-init user code here
        }//GEN-BEGIN:|51-getter|2|
        return fahrenheitStringItem;
    }
//</editor-fold>//GEN-END:|51-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoTextField ">//GEN-BEGIN:|64-getter|0|64-preInit
    /**
     * Returns an initialized instance of pesoTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getPesoTextField() {
        if (pesoTextField == null) {//GEN-END:|64-getter|0|64-preInit
            // write pre-init user code here
            pesoTextField = new TextField("Digite um valor:", "0", 32, TextField.DECIMAL);//GEN-LINE:|64-getter|1|64-postInit
            // write post-init user code here
        }//GEN-BEGIN:|64-getter|2|
        return pesoTextField;
    }
//</editor-fold>//GEN-END:|64-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: pesoChoiceGroup ">//GEN-BEGIN:|65-getter|0|65-preInit
    /**
     * Returns an initialized instance of pesoChoiceGroup component.
     *
     * @return the initialized component instance
     */
    public ChoiceGroup getPesoChoiceGroup() {
        if (pesoChoiceGroup == null) {//GEN-END:|65-getter|0|65-preInit
            // write pre-init user code here
            pesoChoiceGroup = new ChoiceGroup("Escolha a unidade de peso:", Choice.EXCLUSIVE);//GEN-BEGIN:|65-getter|1|65-postInit
            pesoChoiceGroup.append("libra", null);
            pesoChoiceGroup.append("kilograma", null);
            pesoChoiceGroup.append("grama", null);
            pesoChoiceGroup.setSelectedFlags(new boolean[]{false, false, false});//GEN-END:|65-getter|1|65-postInit
            // write post-init user code here
        }//GEN-BEGIN:|65-getter|2|
        return pesoChoiceGroup;
    }
//</editor-fold>//GEN-END:|65-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: libraStringItem ">//GEN-BEGIN:|66-getter|0|66-preInit
    /**
     * Returns an initialized instance of libraStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getLibraStringItem() {
        if (libraStringItem == null) {//GEN-END:|66-getter|0|66-preInit
            // write pre-init user code here
            libraStringItem = new StringItem("libra", "-");//GEN-LINE:|66-getter|1|66-postInit
            // write post-init user code here
        }//GEN-BEGIN:|66-getter|2|
        return libraStringItem;
    }
//</editor-fold>//GEN-END:|66-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: kiloStringItem ">//GEN-BEGIN:|67-getter|0|67-preInit
    /**
     * Returns an initialized instance of kiloStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getKiloStringItem() {
        if (kiloStringItem == null) {//GEN-END:|67-getter|0|67-preInit
            // write pre-init user code here
            kiloStringItem = new StringItem("kilograma", "-");//GEN-LINE:|67-getter|1|67-postInit
            // write post-init user code here
        }//GEN-BEGIN:|67-getter|2|
        return kiloStringItem;
    }
//</editor-fold>//GEN-END:|67-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: gramaStringItem ">//GEN-BEGIN:|68-getter|0|68-preInit
    /**
     * Returns an initialized instance of gramaStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getGramaStringItem() {
        if (gramaStringItem == null) {//GEN-END:|68-getter|0|68-preInit
            // write pre-init user code here
            gramaStringItem = new StringItem("grama", "-");//GEN-LINE:|68-getter|1|68-postInit
            // write post-init user code here
        }//GEN-BEGIN:|68-getter|2|
        return gramaStringItem;
    }
//</editor-fold>//GEN-END:|68-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: compTextField ">//GEN-BEGIN:|72-getter|0|72-preInit
    /**
     * Returns an initialized instance of compTextField component.
     *
     * @return the initialized component instance
     */
    public TextField getCompTextField() {
        if (compTextField == null) {//GEN-END:|72-getter|0|72-preInit
            // write pre-init user code here
            compTextField = new TextField("Digite um valor:", "0", 32, TextField.ANY);//GEN-LINE:|72-getter|1|72-postInit
            // write post-init user code here
        }//GEN-BEGIN:|72-getter|2|
        return compTextField;
    }
//</editor-fold>//GEN-END:|72-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: compChoiceGroup ">//GEN-BEGIN:|73-getter|0|73-preInit
    /**
     * Returns an initialized instance of compChoiceGroup component.
     *
     * @return the initialized component instance
     */
    public ChoiceGroup getCompChoiceGroup() {
        if (compChoiceGroup == null) {//GEN-END:|73-getter|0|73-preInit
            // write pre-init user code here
            compChoiceGroup = new ChoiceGroup("Escolha uma unidade de comprimento:", Choice.EXCLUSIVE);//GEN-BEGIN:|73-getter|1|73-postInit
            compChoiceGroup.append("metro", null);
            compChoiceGroup.append("kilometro", null);
            compChoiceGroup.append("milha", null);
            compChoiceGroup.setSelectedFlags(new boolean[]{false, false, false});//GEN-END:|73-getter|1|73-postInit
            // write post-init user code here
        }//GEN-BEGIN:|73-getter|2|
        return compChoiceGroup;
    }
//</editor-fold>//GEN-END:|73-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: metroStringItem ">//GEN-BEGIN:|80-getter|0|80-preInit
    /**
     * Returns an initialized instance of metroStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getMetroStringItem() {
        if (metroStringItem == null) {//GEN-END:|80-getter|0|80-preInit
            // write pre-init user code here
            metroStringItem = new StringItem("metro", "-");//GEN-LINE:|80-getter|1|80-postInit
            // write post-init user code here
        }//GEN-BEGIN:|80-getter|2|
        return metroStringItem;
    }
//</editor-fold>//GEN-END:|80-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: kmStringItem ">//GEN-BEGIN:|81-getter|0|81-preInit
    /**
     * Returns an initialized instance of kmStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getKmStringItem() {
        if (kmStringItem == null) {//GEN-END:|81-getter|0|81-preInit
            // write pre-init user code here
            kmStringItem = new StringItem("kilometro", "-");//GEN-LINE:|81-getter|1|81-postInit
            // write post-init user code here
        }//GEN-BEGIN:|81-getter|2|
        return kmStringItem;
    }
//</editor-fold>//GEN-END:|81-getter|2|

//<editor-fold defaultstate="collapsed" desc=" Generated Getter: milhaStringItem ">//GEN-BEGIN:|82-getter|0|82-preInit
    /**
     * Returns an initialized instance of milhaStringItem component.
     *
     * @return the initialized component instance
     */
    public StringItem getMilhaStringItem() {
        if (milhaStringItem == null) {//GEN-END:|82-getter|0|82-preInit
            // write pre-init user code here
            milhaStringItem = new StringItem("milha", "-");//GEN-LINE:|82-getter|1|82-postInit
            // write post-init user code here
        }//GEN-BEGIN:|82-getter|2|
        return milhaStringItem;
    }
//</editor-fold>//GEN-END:|82-getter|2|



    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay () {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable (null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet ();
        } else {
            initialize ();
            startMIDlet ();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }

}
